//
//  CatImageView.m
//  TomCat
//
//  Created by aaaaaa on 16/6/9.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "CatImageView.h"

@implementation CatImageView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame withImageName:(NSString *)imageName withImageType:(NSString *)imageType withImageCount:(NSInteger)imageCount{
    self = [super initWithFrame:frame];
//    self.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"angry_00" ofType:@"jpg"]];
    
    
    if (self) {
        NSMutableArray<UIImage *> *imageArray = [NSMutableArray arrayWithCapacity:0];
        for (int i = 0; i < imageCount; i++) {
            NSString *imageStr = [NSString stringWithFormat:@"%@_%02d", imageName, i];
            NSString *imagePath = [[NSBundle mainBundle] pathForResource:imageStr ofType:imageType];
            UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
            [imageArray addObject:image];
        }
        
        self.animationImages = imageArray;
        self.animationDuration = imageCount * 0.1;
        self.animationRepeatCount = 1;
    }
    return self;
}


@end
